package leetcode;

import leetcode.bean.TreeNode;

/**
 * https://leetcode.com/problems/find-bottom-left-tree-value/?tab=Description
 * @program: brushing
 * @description:
 * @author: LiuQiang
 * @create: 2018-07-25 10:37
 **/
public class FindBottomLeftTreeValue {
    // TODO: 2018/7/26
    public int test(TreeNode root) {
        if (root == null) {
            return 0;
        }

        this.test(root.getLeft());
        this.test(root.getRight());
        System.out.println(root.getVal());
        return root.getVal();
    }

    public void t(TreeNode root) {
        if (root == null) {
            return;
        }

        this.t(root.getLeft());
        this.t(root.getRight());
        System.out.println(root.getVal());
    }

    public static void main(String[] args) {
        FindBottomLeftTreeValue f = new FindBottomLeftTreeValue();
        TreeNode t = new TreeNode(5);
        TreeNode t1 = new TreeNode(4);
        TreeNode t2 = new TreeNode(3);
        TreeNode t3 = new TreeNode(2);
        TreeNode t4 = new TreeNode(1);

        t.setLeft(t1);
        t.setRight(t2);
        t1.setLeft(t3);
        t1.setRight(t4);
        //System.out.println(f.test(t));
        //f.t(t);
        System.out.println(f.test(t));
    }
}
